import request from '@/utils/request'
import $ from 'jquery'

/**
 * 获取所有的雇员
 */
export function getWages(currentPage, pageSize, limit) {
  return request({
    url: '/wage/list.json?limit=' + limit,
    method: 'post',
    data: {
      'detailDepart': true,
      'pageQueryParam': {
        pageSize, currentPage
      }
    }
  })
}

export function genWages(a, b, c, d, departId) {
  return request({
    url: '/wage/genWage.action?startYear=' + a + '&startMonth=' + b + '&endYear=' + c + '&endMonth=' + d + '&departId=' + departId,
    method: 'get'
  })
}

export function modWageInfo(id, benefitBonus, deBonus, deleteFlag) {
  return request({
    url: '/wage/mod.do?id=' + id + '&benefitBonus=' + benefitBonus + '&deBonus=' + deBonus + '&deleteFlag=' + deleteFlag,
    method: 'get'
  })
}

export function exportExcel(filename, year, month) {
  const url = 'http://localhost:10003/api/wage/export.do?filename=' + filename + '&year=' + year + '&month=' + month
  const form = $('<form></form>').attr('action', url).attr('method', 'get')
  form.append($('<input/>').attr('type', 'hidden').attr('name', 'filename').attr('value', filename))
  form.append($('<input/>').attr('type', 'hidden').attr('name', 'year').attr('value', year))
  form.append($('<input/>').attr('type', 'hidden').attr('name', 'month').attr('value', month))
  form.appendTo('body').submit().remove()
}

